package aes.client;

import java.awt.*;
import java.awt.event.*;
import java.util.*;

import javax.swing.*;
import javax.swing.border.*;

public class ExamExecutionTeacherUI extends JPanel implements ActionListener, Observer{
	
	private ClientUI ui;
	@SuppressWarnings("unused")
	private Client c;
	
	private JPanel panel_1;
	private JPanel panel_2;
	private JButton btnManualExam;
	private JButton btnComputerExam;
	private JButton btnBack;
	private JButton btnExamExecutionManager;
	/**
	 * 
	 */
	private static final long serialVersionUID = -7310485145883321562L;

	
	public ExamExecutionTeacherUI(Client c,ClientUI ui){
		super();
		this.c = c;
		this.ui = ui;
		
		JFrame frame = new JFrame();
		frame.setSize(640, 480);
		frame.getContentPane().add(this);
		
		c.addObserver(this);
		setLayout(new GridBagLayout());

		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
		panel.setPreferredSize(new Dimension(600,400));
		
		GridBagConstraints gbc_panel = new GridBagConstraints();
		gbc_panel.insets = new Insets(5, 0, 5, 0);
		gbc_panel.gridx = 0;
		gbc_panel.gridy = 0;
		add(panel,gbc_panel);
		
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 1.0};
		gbl_panel.columnWeights = new double[]{1.0};
		
		panel.setLayout(gbl_panel);
		
		btnExamExecutionManager = new JButton("Exam Execution Manager");
		btnExamExecutionManager.setIcon(new ImageIcon(ExamExecutionTeacherUI.class.getResource("/aes/client/images/Exam.png")));
		btnExamExecutionManager.addActionListener(this);
		GridBagConstraints gbc_btnExamExecutionManager = new GridBagConstraints();
		gbc_btnExamExecutionManager.insets = new Insets(20, 0, 5, 0);
		gbc_btnExamExecutionManager.anchor=GridBagConstraints.CENTER;
		gbc_btnExamExecutionManager.gridx = 0;
		gbc_btnExamExecutionManager.gridy = 1;
		panel.add(btnExamExecutionManager, gbc_btnExamExecutionManager);
		
		panel_1 = new JPanel();
		GridBagConstraints gbc_panel_1 = new GridBagConstraints();
		gbc_panel_1.insets = new Insets(0, 0, 5, 0);
		gbc_panel_1.fill = GridBagConstraints.BOTH;
		gbc_panel_1.gridx = 0;
		gbc_panel_1.gridy = 2;
		panel.add(panel_1, gbc_panel_1);
		panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 100, 5));
		
		btnManualExam = new JButton("Manual Exam", new ImageIcon(MainUI.class.getResource("/aes/client/images/manual.png")));
		btnManualExam.addActionListener(this);
		
		GridBagConstraints gbc_btnManualExam = new GridBagConstraints();
		gbc_btnManualExam.insets = new Insets(5, 5, 5, 5);
		panel_1.add(btnManualExam, gbc_btnManualExam);
		btnManualExam.setBounds(353, 7, 57, 23);
		
		btnComputerExam = new JButton("Computerized Exam", new ImageIcon(MainUI.class.getResource("/aes/client/images/computerized.png")));
		btnComputerExam.addActionListener(this); 
		GridBagConstraints gbc_btnComputerExam = new GridBagConstraints();
		gbc_btnComputerExam.insets = new Insets(5, 5, 5, 5);
		panel_1.add(btnComputerExam, gbc_btnComputerExam);
		btnComputerExam.setBounds(353, 7, 57, 23);
		
		
		panel_2 = new JPanel();
		GridBagConstraints gbc_panel_2 = new GridBagConstraints();
		gbc_panel_2.insets = new Insets(30, 0, 0, 0);
		gbc_panel_2.fill = GridBagConstraints.BOTH;
		gbc_panel_2.gridx = 0;
		gbc_panel_2.gridy = 4;
		panel.add(panel_2, gbc_panel_2);
		panel_2.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
		
		btnBack = new JButton("Back", new ImageIcon(ExamsManagerUI.class.getResource("/aes/client/images/back.png")));
		btnBack.addActionListener(this); 
		GridBagConstraints gbc_btnBack = new GridBagConstraints();
		gbc_btnBack.insets = new Insets(5, 5, 5, 5);
		panel_2.add(btnBack, gbc_btnBack);
		btnBack.setBounds(353, 7, 57, 23);
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		// TODO Auto-generated method stub
		
	}

	@SuppressWarnings("static-access")
	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource().equals(btnComputerExam)) {
			ui.SetContent(ui.TEACHER_EXAM_COMPUTERIZED_EXECUTION_SCREEN);
		}
		else if (e.getSource().equals(btnManualExam)) {
			ui.SetContent(ui.TEACHER_EXAM_MANUAL_EXECUTION_SCREEN);
		}
		else if (e.getSource().equals(btnBack)) {
			ui.SetContent(ui.MAIN_SCREEN);
		}
		else if (e.getSource().equals(btnExamExecutionManager)) {
			ui.SetContent(ui.EXAM_EXECUTION_MANAGER_SCREEN);
		}
	}

}
